package com.es.dao;

import org.apache.log4j.Logger;

import com.es.dao.factory.SqlMapClientFactory;
import com.es.exception.dao.ESDataAccessException;
import com.es.model.Contact;
import com.ibatis.sqlmap.client.SqlMapClient;

public class ContactDAO extends BaseDAO {
	
	private static final Logger log = Logger.getLogger(ContactDAO.class);


	/**
	 * @author Bushra
	 * save contact's  model object in the repositary
	 * @param 'contact' model object
	 * @return contact id generated by db
	 * @throws ESDataAccessException
	 */

	public  int saveContact(Contact contact) throws ESDataAccessException {

		log.info(" inside saveContact() "); 
		log.info("SAVING CONTACT..");

		SqlMapClient sqlMap =  SqlMapClientFactory.getSqlMapClient();
		int contactID = -1;

		try {
			contactID =(Integer) sqlMap.insert("contact.abatorgenerated_insert", contact);
			log.info("SAVED CONTACT ID :" + contactID);
			return contactID;
		} catch (Exception e) {
			log.error(e);
			throw new ESDataAccessException(e);

		}
	}



}
